//---------------------------------------------------------------------------
#ifndef CRadBtnH
#define CRadBtnH
//---------------------------------------------------------------------------

#include <SysUtils.hpp>
#include <sysinit.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include "CtrlStd.h"
#include "Messages.h"

#define RAY_OPTION              6
#define DEFAULT_WIDTH         110
#define DEFAULT_HEIGHT         17
#define SIZE_ESP                5
#define COL_EDIT_RADBTN                 clBtnHighlight


enum TRadButAlign   { eRdButLeftAlign, eRdButRightAlign };
enum StateCheck     { eChecked, eUnChecked, eDisabledChecked, eDisabledUnChecked };

//---------------------------------------------------------------------------
class PACKAGE_CTRLSTD CRadioButton : public TCustomControl
    {
    private:
		typedef TCustomControl inherited;
		typedef void __fastcall (__closure *TNotifyEvent)(System::TObject* Sender, bool bIsChecked );
        bool                FChecked;
        bool                FReadOnly;
		enum TRadButAlign   FAlignment;
		TNotifyEvent 		FOnCheck;
      int m_iGroupe;
      AnsiString m_Reference;
      AnsiString m_asRefWebHelp;

	__published:
        __property AnsiString  RefWebHelp           = {read = m_asRefWebHelp, write = SetRefWebHelp };
		__property enum TRadButAlign    Alignment   = { read=FAlignment,    write=SetAlignment, default = eRdButLeftAlign    };
		__property                      Color;
		__property                      Caption     = { read=GetCaption,    write=SetCaption,   default = NULL          };
		__property bool                 Checked     = { read=FChecked,      write=SetChecked,   default = false         };
      __property                      Enabled     = { read=GetEnabled,    write=SetEnabled,   default = true          };
      __property                      DragCursor;
		__property                      DragMode;
      __property                      Font;
      __property                      HelpContext;
      __property                      Hint;
      __property                      ParentColor;
      __property                      ParentFont;
      __property                      ParentShowHint;
      __property                      PopupMenu;
      __property bool                 ReadOnly    = { read=FReadOnly,     write=SetReadOnly,  default = false         };
      __property                      ShowHint;
      __property                      TabOrder;
      __property                      TabStop;
      __property                      Visible;
      __property int                  Groupe = {read = m_iGroupe, write = m_iGroupe, default = 0};
      __property AnsiString           Reference = { read=m_Reference, write=m_Reference};


    // Evenements
        __property OnStartDrag;
        __property OnDragDrop;
        __property OnDragOver;
        __property OnEndDrag;
        __property OnKeyDown;
        __property OnKeyPress;
        __property OnKeyUp;
        __property OnEnter;
        __property OnExit;
        __property OnMouseDown;
        __property OnMouseMove;
        __property OnMouseUp;
        __property OnClick;
		__property OnDblClick;
		__property TNotifyEvent OnCheck = {read=FOnCheck, write=FOnCheck};

    private:
        void        __fastcall SetRefWebHelp(const AnsiString    asValeur) { m_asRefWebHelp = asValeur;};
        void        __fastcall SetAlignment(    enum TRadButAlign   AAlignment  );
        void        __fastcall SetCaption( const AnsiString         aCaption    );
        void        __fastcall SetChecked(      bool                bChecked    );
        void        __fastcall SetEnabled(      bool                bEnabled    );
        void        __fastcall SetReadOnly(     bool                bReadOnly   );
        AnsiString  __fastcall GetCaption() /*const*/;
        bool        __fastcall GetEnabled();

    private:
        Graphics::TBitmap   *BmpOption;
        TLabel              *LCaption;
		bool                bFocused;

    protected:
        virtual void __fastcall Paint();
        virtual void __fastcall WndProc( TMessage &Message );
        DYNAMIC void __fastcall Click();
        DYNAMIC void __fastcall KeyPress( char &Key );
        DYNAMIC void __fastcall KeyDown(Word &Key, Classes::TShiftState Shift);
        void __fastcall CaptionClick( TObject *Sender );
        void __fastcall DrawContour( bool bVisible );
        void __fastcall DrawCheck( enum StateCheck eState );
		void __fastcall UncheckedLast();
		bool __fastcall IsAnotherChecked();

    private:
        void __fastcall LoadBmpOption();
        void __fastcall InitCaption();

    public:
                __fastcall  CRadioButton(TComponent* Owner);
        virtual __fastcall ~CRadioButton( void);
    };
#endif
